// 前端在发送请求时，所有的header中都要保存user_token
$(document).ajaxSend(function(e, xhr, opt) {
    var user_token = localStorage.getItem("user_token");
    xhr.setRequestHeader("user_token",user_token);
});

// 获取用户信息
function getUserInfo(url) {
    $.ajax({
        type : "post",
        url : url,
        success : function (result) {
            if (result.code == "SUCCESS" && result.data != null) {
                var data = result.data;
                $(".container .left .card h3").text(data.userName);
                $(".container .left .card a").attr("href",data.githubUrl);
                $("#size").text(data.blogSize);
            } else {
                console.log("用户信息错误");
                
            }
        }
    });
}

// 退出登录（注销）
function logout(){
    localStorage.removeItem("user_token");
    location.href = "blog_login.html";
}